package com.${input.projects}.application.${input.modules}.domain;

import com.enterprise.support.utility.Enterprise;

import javax.persistence.*;
import java.util.Date;
import java.util.Map;
/**
* Created by Enterprise Tools
* Date: ${input.date?string("yyyy-MM-dd hh:mm:ss")}
* Email: z82422@gmail.com
* Hibernate Domain
*/

@Entity
<#if !input.isEmpty("tablename")>
@Table(name = "${input.tablename}")
</#if>
public class ${input.entityName} extends Enterprise {

public ${input.entityName}() {
super();
}

public ${input.entityName}(Map entity) {
super(entity);
}

<#list input.propertys.model.dataVector as property>
    <#if property[0]=="id">
    <@generatorField property input/>
    </#if>
</#list>

<#list input.propertys.model.dataVector as property>
    <#if property[0]!="id">
    <@generatorField property input/>

    </#if>
</#list>

}

<#-- 定义生成字段 宏。。。。。-->
<#macro generatorField property input>
    <#if property[0]=="id">
    @Id
        <#if input.dbtype?index_of("oracle")==-1>
        @GeneratedValue(strategy = javax.persistence.GenerationType.AUTO)
            <#else>
            @SequenceGenerator(name="SEQ_${input.tablename?upper_case}_Generator",sequenceName="SEQ_${input.tablename?upper_case}",allocationSize=1,initialValue=1)
            @GeneratedValue(generator="SEQ_${input.tablename?upper_case}_Generator",strategy=GenerationType.SEQUENCE)
        </#if>
        <#else>
        @Basic
        @Column(name="${property[0]?lower_case}")
    </#if><#t/>
public ${property[1]?trim} get${property[0]?cap_first}(){
return get${property[1]?trim}("${property[0]}");
}
public void set${property[0]?cap_first}(${property[1]?trim} ${property[0]}){
set("${property[0]}",${property[0]});
}
</#macro>